/// <reference path="_variables-shared.scss" />
/// <reference path="_mixins.scss" />
/// <reference path="../lib/bs4/scss/bootstrap.scss" />

// Forms
// ------------------------------------------------------

input, 
textarea, 
select {
    // Overwrite UserAgent stylesheet (400)
    font-weight: $font-weight-normal;
}

fieldset.content-group {
    margin-bottom: 2rem;

    > legend {
        position: relative;
        font-size: $h5-font-size;
        font-weight: $font-weight-normal;
        color: $gray-500;
        text-transform: uppercase;
        margin-bottom: 1.2rem;

        &:before {
            position: absolute;
            content: ' ';
            width: 100%;
            left: 0;
            top: 50%;
            height: 1px;
            background: rgba(0,0,0, 0.12);
            z-index: 0;
        }

        > span {
            position: relative;
            display: inline-block;
            @if alpha($body-bg) == 0 {
                background: $site-bg;
            }
            @else {
                background: $body-bg;
            }
            
            padding-right: 1rem;
            z-index: 1;
        }
    }
}

.form-group label:not(.form-check-label):not(.custom-control-label) {
	font-weight: $font-weight-medium;
}

.required > label:after {
    content: ' *';
}

.form-text {
    line-height: 1.3;
}


// Control with Icons
// ------------------------------------------------------

.has-icon {
	position: relative;
	display: flex;

	.form-control {
		position: relative;
		z-index: 2;
	}

	.input-group-icon {
		position: absolute;
		left: 0;
		z-index: 10;
		width: $input-height;
		height: 100%;
		line-height: $input-height;
		text-align: center;
		vertical-align: middle;

        :before {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
	}

	&.has-icon-right .input-group-icon {
		left: auto;
		right: 0;
	}

	&.input-group-lg .input-group-icon {
		width: $input-height-lg;
		height: $input-height-lg;
		line-height: $input-height-lg;
		font-size: $font-size-lg;
	}

	&.input-group-sm .input-group-icon {
		width: $input-height-sm;
		height: $input-height-sm;
		line-height: $input-height-sm;
		font-size: $font-size-sm;
	}

	&:not(.has-icon-right) {
		.form-control {
			padding-left: $input-height;
		}

		&.input-group-lg .form-control {
			padding-left: $input-height-lg;
		}

		&.input-group-sm .form-control {
			padding-left: $input-height-sm;
		}
	}

	&.has-icon-right {
		.form-control {
			padding-right: $input-height;
		}

		&.input-group-lg .form-control {
			padding-right: $input-height-lg;
		}

		&.input-group-sm .form-control {
			padding-right: $input-height-sm;
		}
	}
}


// Checkbox & Radio tweaks
// ------------------------------------------------------

.radio input[type="radio"], 
.radio-inline input[type="radio"], 
.checkbox input[type="checkbox"], 
.checkbox-inline input[type="checkbox"] {
    margin-right: 0.25rem;
}

.wkit.touchevents .form-check {
	@if $font-size-base < 1 rem {
        // Fix Chrome mobile check/radio alignment and padding issues:
        // increase spacing from 1.25rem to 1.5rem
		padding-left: 1.5rem;
	
		.form-check-input {
			margin-left: -1.5rem;
		}
	
		.form-check-label {
			padding-top: 0.2rem;
		}
	}
}


// Custom range
// ------------------------------------------------------

.custom-range {
    // INFO: Autoprefixer does not run in debug mode
    -webkit-appearance: none;
    -moz-appearance: none;

    &::-webkit-slider-thumb { -webkit-appearance: none; }
    &::-moz-range-thumb     { -moz-appearance: none; }
}


// Validation
// ------------------------------------------------------

.validation-summary-valid,
.validation-summary-errors {
    @extend .alert;

    > *:last-child {
        margin-bottom: 0;
    }
}

.validation-summary-valid {
    display: none;
    @extend .alert-success; 
}

.validation-summary-errors {
    @extend .alert-danger;
}

.field-validation-error,
.field-validation-valid {
    display: block;
    font-size: $font-size-sm;
    width: 100%;

    &:not(:empty) {
        margin-top: 0.25rem;
    }
}

.field-validation-error {
	color: $form-feedback-invalid-color;
}

.field-validation-valid {
	color: $form-feedback-valid-color;
}

.is-valid,
.is-invalid {
	&:focus {
		box-shadow: none !important;
	}
}


//
// Honeypot
// ------------------------------------------------------

.required-text-input {
	display: none;
}


//
// Link Builder (maybe move to custom file later)
// ------------------------------------------------------

.link-control > .form-control,
.link-control > .select2 {
	border-radius: 0 !important;
	border-color: $input-border-color !important;

	.select2-selection {
		border-radius: 0 !important;
	}
}

.link-control > .form-control:focus {
	outline: 1px solid $input-focus-border-color;
	outline-offset: -2px;
}